/* GUI CONVERTED from rsdel.p (converter v1.75) Sat Aug 12 23:13:59 2000 */
/* rsdel.p - Release Management Supplier Schedules                          */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                      */
/* All rights reserved worldwide.  This is an unpublished work.             */
/*F0PN*/ /*V8:ConvertMode=Report                                            */
/*K1Q4*/ /*V8:RunMode=Character,Windows                                     */
/* REVISION: 7.0    LAST MODIFIED: 01/29/92           BY: WUG *F110*        */
/* REVISION: 7.0    LAST MODIFIED: 03/20/92           BY: WUG *F312*        */
/* REVISION: 7.0    LAST MODIFIED: 03/26/92           BY: WUG *F323*        */
/* REVISION: 7.3    LAST MODIFIED: 12/10/92           BY: WUG *G462*        */
/* REVISION: 7.4    LAST MODIFIED: 09/29/93           BY: WUG *H142*        */
/* REVISION: 7.3    LAST MODIFIED: 04/14/94           BY: WUG *GJ34*        */
/* REVISION: 7.3    LAST MODIFIED: 03/03/95           BY: aed *G0JC*        */
/* REVISION: 8.5    LAST MODIFIED: 02/28/96     BY: *J0CV* Brandy J Ewing   */
/* REVISION: 8.5    LAST MODIFIED: 04/21/97     BY: *G2MD* Aruna Patil      */
/* REVISION: 8.6    LAST MODIFIED: 05/01/97     BY: *K0CV* Vinay Nayak-Sujir*/

/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan       */
/* REVISION: 8.6E     LAST MODIFIED: 08/14/98   BY: *J2SN* Dana Tunstall    */
/* REVISION: 9.0      LAST MODIFIED: 12/01/98   BY: *K1QY* Pat McCormick    */
/* REVISION: 9.0      LAST MODIFIED: 03/13/99   BY: *M0BD* Alfred Tan       */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00 BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/09/00   BY: *M0QW* Falguni Dalal    */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb              */

/* SCHEDULE ARCHIVE/DELETE */

         /* DISPLAY TITLE */

/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

/*J0CV*/ {mfdtitle.i "b+ "}

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE rsdel_p_1 "Archive"
/* MaxLen: Comment: */

&SCOPED-DEFINE rsdel_p_2 "Delete"
/* MaxLen: Comment: */

&SCOPED-DEFINE rsdel_p_3 "Archive File"
/* MaxLen: Comment: */

&SCOPED-DEFINE rsdel_p_4 "Created"
/* MaxLen: Comment: */

&SCOPED-DEFINE rsdel_p_5 "Detail Only"
/* MaxLen: Comment: */

&SCOPED-DEFINE rsdel_p_6 "Inactive Schedule Only"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

define new shared variable supplier_from like po_vend.
define new shared variable supplier_to like po_vend.
define new shared variable shipto_from like po_ship.
define new shared variable shipto_to like po_ship.
define new shared variable part_from like pod_part.
define new shared variable part_to like pod_part.
define new shared variable po_from like po_nbr.
define new shared variable po_to like po_nbr.
define new shared variable buyer_from like po_buyer.
define new shared variable buyer_to like po_buyer.
define new shared variable date_from as date label {&rsdel_p_4}.
define new shared variable date_to as date.
define new shared variable detail_only like mfc_logical label {&rsdel_p_5}.
define variable rdelete like mfc_logical label {&rsdel_p_2}.
/*G0JC*/ define variable archive like mfc_logical label {&rsdel_p_1} initial no.
define variable filename as character format "x(12)" label {&rsdel_p_3}.
define stream history.
/* /*K0CV*/ define  variable  inactive_only as logical initial yes      **M0QW*/
define  variable  inactive_only like mfc_logical initial yes            /*M0QW*/
/*K0CV*/     label {&rsdel_p_6} no-undo.

/**J0CV** {mfdtitle.i "b+ "} **/


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
po_from              colon 20
   po_to                colon 50 label {t001.i}
   part_from            colon 20
   part_to              colon 50 label {t001.i}
   supplier_from        colon 20
   supplier_to          colon 50 label {t001.i}
   shipto_from          colon 20
   shipto_to            colon 50 label {t001.i}
   buyer_from           colon 20
   buyer_to             colon 50 label {t001.i}
   date_from                colon 20
   date_to                colon 50 label {t001.i}
   skip(1)
/*K0CV*/ inactive_only  colon 35
   detail_only                colon 35
   skip(1)
   rdelete                colon 35
   archive                colon 35
   filename               colon 35
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

/*G0JC*/ repeat /* with frame a */:
   output stream history close.

   if po_to = hi_char then po_to = "".
   if part_to = hi_char then part_to = "".
   if supplier_to = hi_char then supplier_to = "".
   if shipto_to = hi_char then shipto_to = "".
   if buyer_to = hi_char then buyer_to = "".

/*G2MD**   if date_from = 01/01/1960 then date_from = ?. */
/*G2MD**   if date_to = 12/31/2100 then date_to = ?.     */

/*G2MD*/ if date_from = low_date then date_from = ?.
/*G2MD*/ if date_to = hi_date then date_to = ?.

   update
   po_from
   po_to
   part_from
   part_to
   supplier_from
   supplier_to
   shipto_from
   shipto_to
   buyer_from
   buyer_to
   date_from
   date_to
/*K0CV*/ inactive_only
           detail_only
/*G0JC*/   rdelete
/*G0JC*/   archive

/*G0JC*/ with frame a.

   if po_to = "" then po_to = hi_char.
   if part_to = "" then part_to = hi_char.
   if supplier_to = "" then supplier_to = hi_char.
   if shipto_to = "" then shipto_to = hi_char.
   if buyer_to = "" then buyer_to = hi_char.

/*G2MD**   if date_from = ? then date_from = 01/01/1960. */
/*G2MD**   if date_to = ? then date_to = 12/31/2100.     */

/*G2MD*/ if date_from = ? then date_from = low_date.
/*G2MD*/ if date_to = ? then date_to = hi_date.

/*K0CV*/ if inactive_only = no then do:
/*K0CV*/    {mfmsg.i 8106 2}
/*K0CV*/    /* ACTIVE SCHEDULES WOULD ALSO BE DELETED */
/*K0CV*/ end.

   if rdelete then do:
/*G0JC** update archive with frame a. */
      if archive then do:
/*J2SN** BEGIN DELETE **
 *        filename = string(today,"999999").
 *        /*GJ34 CHANGE FILENAME PREFIX FROM RS TO SS*/
 *        filename = "ss" + substring(filename,5,2) + substring(filename,1,2)
 *        + substring(filename,3,2).
 *        filename = filename + ".hst".
 *J2SN** END DELETE **/

/*J2SN*/   filename = "ss"
/*J2SN*/              + substring(string(year(today),"9999"),3,2)
/*J2SN*/              + string(month(today),"99")
/*J2SN*/              + string(day(today),"99")
/*J2SN*/              + ".hst".
         display filename with frame a.
         {mfmsg.i 51 1}
         /* Note: archive files should be backed up and deleted from disk */

         if search(filename) <> ? then do:
            {mfmsg03.i 52 2 filename """" """"}
            /* WARNING: <filename> exists, archive data will be appended */
         end.
         output stream history to value(filename) append.
      end.
/*G0JC*/     else do:
/*G0JC*/        display "" @ filename with frame a.
/*G0JC*/     end.
      end.
      else do:
/*G0JC*/     display "" @ filename with frame a.
/*G0JC*/     if archive then do:
/*G0JC*/        {mfmsg.i 7739 3}
/*G0JC*/        undo, retry.
/*G0JC*/     end.
   end.

   {mfselprt.i "printer" 80}
/*GUI*/ RECT-FRAME:HEIGHT-PIXELS in frame a = FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.

   {mfphead2.i}

   for each scx_ref no-lock
   where scx_type = 2
   and scx_shipfrom >= supplier_from and scx_shipfrom <= supplier_to
   and scx_shipto >= shipto_from and scx_shipto <= shipto_to
   and scx_part >= part_from and scx_part <= part_to
   and scx_po >= po_from and scx_po <= po_to,
/*K0CV* each pod_det no-lock */
/*K0CV*/ each pod_det exclusive-lock
   where pod_nbr = scx_order and pod_line = scx_line,
   each po_mstr no-lock
   where po_nbr = pod_nbr
   and po_buyer >= buyer_from and po_buyer <= buyer_to
   break by scx_shipto by scx_shipfrom by scx_part by scx_po:

/*K1QY*/ /* PROCESS SUPPLIER SCHEDULE */

  for each sch_mstr exclusive-lock
       where sch_type = 4
         and sch_nbr = pod_nbr and sch_line = pod_line
         and sch_cr_date >= date_from and sch_cr_date <= date_to
/*K0CV*  and sch_rlse_id <> pod_curr_rlse_id[1]: */
/*K0CV*/ and (not inactive_only or
/*K0CV*/      inactive_only and sch_rlse_id <> pod_curr_rlse_id[1]):

/*K1QY*/ run process_sched (input recid(sch_mstr),
                            input recid(pod_det)).
/*K1QY*/ end. /* for each sch_mstr, type = 4 */

/*K1QY*/ /* PROCESS PLANNING SCHEDULES */

/*K1QY*/ for each sch_mstr exclusive-lock
/*K1QY*/ where sch_type = 5
/*K1QY*/ and sch_nbr = pod_nbr and sch_line = pod_line
/*K1QY*/ and sch_cr_date >= date_from and sch_cr_date <= date_to
/*K1QY*/ and (not inactive_only or
/*K1QY*/      inactive_only and sch_rlse_id <> pod_curr_rlse_id[2]):

/*K1QY*/ run process_sched (input recid(sch_mstr),
                            input recid(pod_det)).
/*K1QY*/ end. /* for each sch_mstr, type = 5 */

/*K1QY*/ /* PROCESS SHIPPING SCHEDULES */

/*K1QY*/ for each sch_mstr exclusive-lock
/*K1QY*/ where sch_type = 6
/*K1QY*/ and sch_nbr = pod_nbr and sch_line = pod_line
/*K1QY*/ and sch_cr_date >= date_from and sch_cr_date <= date_to
/*K1QY*/ and (not inactive_only or
/*K1QY*/      inactive_only and sch_rlse_id <> pod_curr_rlse_id[3]):

/*K1QY*/ run process_sched (input recid(sch_mstr),
                            input recid(pod_det)).
/*K1QY*/ end. /* for each sch_mstr, type = 6 */

/*K1QY*/ end. /* for each scx_ref */

   output stream history close.
   {mftrl080.i}
end. /* repeat */

/*K1QY*/ /* INTERNAL PROCEDURE TO PROCESS SCHEDULE ARCHIVE/DELETE */

/*K1QY*/ PROCEDURE process_sched:

/*K1QY*/ define input parameter sch_recid as recid no-undo.
/*K1QY*/ define input parameter pod_recid as recid no-undo.

/*K1QY*/ for first sch_mstr where recid(sch_mstr) = sch_recid exclusive-lock:
/*K1QY*/ end.

/*K1QY*/ for first pod_det where recid(pod_det) = pod_recid exclusive-lock:
/*K1QY*/ end.

         {gprun.i ""rsiq1a.p"" "(input sch_type,
         input sch_nbr, input sch_line, input sch_rlse_id, input no,
         input no)"}    /*J0CV*/ /* ADDED TO SUPPORT NEW INPUT PARAMETER */

         if rdelete then do:
            for each schd_det no-lock
            where schd_type = sch_type
            and schd_nbr = sch_nbr
            and schd_line = sch_line
            and schd_rlse_id = sch_rlse_id:
               if archive then do:
                  export stream history "schd_det".
                  export stream history schd_det.
               end.
            end.

            if archive and not detail_only then do:
               export stream history "sch_mstr".
               export stream history sch_mstr.
            end.

/*K1QY*/    /* DELETE SUPPLIER SCHEDULES */
/*K0CV*/    /* Active schedule delete processing */
/*K1QY*/    if sch_type = 4 then do:
/*K0CV*/       if pod_curr_rlse_id[1] = sch_rlse_id then do:
/*K0CV*/          pod_curr_rlse_id[1] = "".

/*K0CV*/          {gprun.i ""rcschdel.p"" "(input sch_recid,
                                            input detail_only)"}
/*K0CV*/    /* Remove mrp_det records for the schedule */
/*K0CV*/          {gprun.i ""rsmrw.p"" "(input pod_nbr,
                                         input pod_line,
                                         input yes)"}
/*K0CV*/       end. /* if pod_curr_rlse_id[1] = ... */
/*K0CV*/       else do:
                   {gprun.i ""rcschdel.p"" "(input sch_recid,
                                             input detail_only)"}
/*K0CV*/       end.
/*K1QY*/       next.
/*K1QY*/    end. /* if sch_type = 4 */

/*K1QY*/    /* DELETE PLANNING SCHEDULE */
/*K1QY*/    if sch_type = 5 then do:
/*K1QY*/       if pod_curr_rlse_id[2] = sch_rlse_id then do:
/*K1QY*/          pod_curr_rlse_id[2] = "".
/*K1QY*/          {gprun.i ""rcschdel.p"" "(input sch_recid,
                                            input detail_only)"}
/*K1QY*/    /* Remove mrp_det records for the schedule */
/*K1QY*/          {gprun.i ""rsmrw.p"" "(input pod_nbr,
                                         input pod_line,
                                         input yes)"}
/*K1QY*/       end. /* if pod_curr_rlse_id[1] = ... */
/*K1QY*/       else do:
/*K1QY*/          {gprun.i ""rcschdel.p"" "(input sch_recid,
                                            input detail_only)"}
/*K1QY*/       end.
/*K1QY*/       next.
/*K1QY*/    end. /* if sch_type = 5 */

/*K1QY*/    /* DELETE SHIPPING SCHEDULE */
/*K1QY*/    if sch_type = 6 then do:
/*K1QY*/       if pod_curr_rlse_id[3] = sch_rlse_id then do:
/*K1QY*/          pod_curr_rlse_id[3] = "".
/*K1QY*/          {gprun.i ""rcschdel.p"" "(input sch_recid,
                                            input detail_only)"}
/*K1QY*/    /* Remove mrp_det records for the schedule */
/*K1QY*/          {gprun.i ""rsmrw.p"" "(input pod_nbr,
                                         input pod_line,
                                         input yes)"}
/*K1QY*/       end. /* if pod_curr_rlse_id[1] = ... */
/*K1QY*/       else do:
/*K1QY*/          {gprun.i ""rcschdel.p"" "(input sch_recid,
                                            input detail_only)"}
/*K1QY*/       end.
/*K1QY*/       next.
/*K1QY*/    end. /* if sch_type = 6 */
         end. /* if rdelete */

/*K1QY*/ /* MOVED FOLLOWING CODE OUTSIDE INTERAL PROCEDURE */
/*K1QY**
 *      end.
 *    end.
 *
 *    output stream history close.
 *    {mftrl080.i}
 * end.
 *K1QY**/

/*K1QY*/ end. /* Procedure process_sched */
